#ifndef _DRV_FIFO_H_
#define _DRV_FIFO_H_

#include <stdint.h>
#include <stdio.h>


#define USE_MALLOC 1
#define USE_LOCK 0
#define STATIC_FIFO_SIZE 4096

//FIFO 环形队列
typedef struct _QUEUE
{
	volatile uint16_t head;
	volatile uint16_t tail;
	uint16_t max;
#if USE_MALLOC
	uint8_t *data;
#else
	uint8_t data[STATIC_FIFO_SIZE];
#endif
} QUEUE;

void queue_init(QUEUE *que, uint8_t *dp, uint16_t len);
void queue_reset(QUEUE *que);

void queue_push(QUEUE *que, uint8_t *data, uint16_t size);
void queue_pop_data(QUEUE *que, uint8_t *data, uint16_t size);
void queue_calc_tail(QUEUE *que, uint8_t size);
void queue_pop(QUEUE *que, uint8_t *data);
uint16_t queue_size(QUEUE *que);
void queue_switch(QUEUE *que);


#endif
